//
//  UIButton+Extension.swift
//  Practice
//
//  Created by miaozhihui on 2016/12/2.
//  Copyright © 2016年 DeKuTree. All rights reserved.
//

import UIKit

extension UIButton {
    
    /// 便利构造函数
    ///
    /// - Parameters:
    ///   - imageName: 图像名称
    ///   - backImageName: 背景图像名称
    convenience init(imageName:String,backImageName:String) {
        self.init()
        setImage(UIImage(named: imageName), for: .normal)
        setImage(UIImage(named: imageName + "_highlighted"), for: .highlighted)
        setBackgroundImage(UIImage(named: backImageName), for: .normal)
        setBackgroundImage(UIImage(named: backImageName + "_highlighted"), for: .highlighted)
        sizeToFit()
    }
    
    /// 便利构造函数
    ///
    /// - Parameters:
    ///   - title: title
    ///   - color: color
    ///   - imageName: iamgeName
    convenience init(title:String,color:UIColor,imageName:String) {
        self.init()
        setTitle(title, for: .normal)
        setTitleColor(color, for: .normal)
        setBackgroundImage(UIImage(named: imageName), for: .normal)
        sizeToFit()
    }
}
